<?php

class Component {
    public $id, $owner, $params;
    
    public function __construct (&$owner, $params, $alias) {
        $this->id     = $params['class'];
        $this->owner  = $owner;
        $this->params = $params;
        $this->injectParams($params);
        $this->pushState($alias, &$this);
        $this->init();
    }
    
    public function init () {}
    
    public function injectParams ($params) {
        foreach($params as $param=>$value) {
            $this->$param = $value;
        }
    }
    
    public function pushState ($state, $value) {
        $this->owner->setState($state, $value);
    }
}